#include "getcurrent.h"
#include<sstream>

void gettime(time_t t1, std::string &out) {
        struct tm *t = localtime(&t1);
        std::stringstream ss;
        std::string time, tmp;
        ss << (t->tm_year + 1900);
        ss >> time;
        ss.clear();
        time.insert(time.size(),1,'-');
        ss << (t->tm_mon + 1);
        ss >> tmp;
        ss.clear();
        time.insert(time.size(), tmp);
        time.insert(time.size(),1,'-');
        ss << t->tm_mday;
        ss >> tmp;
        time.insert(time.size(),tmp);
        time.insert(time.size(),1,' ');
        ss << t->tm_hour;
        ss >> tmp;
        ss.clear();
        time.insert(time.size(),tmp);
        time.insert(time.size(),1,':');
        ss << t->tm_min;
        ss >> tmp;
        ss.clear();
        time.insert(time.size(),tmp);
        time.insert(time.size(),1,':');
        ss << t->tm_sec;
        ss >> tmp;
        ss.clear();
        time.insert(time.size(),tmp);
        out = time;
}
